﻿using System;
using Microsoft.Xna.Framework;

namespace GO_Test_1.Tools {

	public static class VectorHelper {

		public static Vector2 RotateVector2(Vector2 point, float radians) {
			float cosRadians = (float) Math.Cos(radians);
			float sinRadians = (float) Math.Sin(radians);

			return new Vector2(point.X*cosRadians-point.Y*sinRadians, point.X*sinRadians+point.Y*cosRadians);
		}

		public static Vector2 RotateVector2(Vector2 point, float radians, Vector2 pivot) {
			float cosRadians = (float) Math.Cos(radians);
			float sinRadians = (float) Math.Sin(radians);

			Vector2 translatedPoint = new Vector2 {X = point.X-pivot.X, Y = point.Y-pivot.Y};

			Vector2 rotatedPoint = new Vector2 {X = translatedPoint.X*cosRadians-translatedPoint.Y*sinRadians+pivot.X, Y = translatedPoint.X*sinRadians+translatedPoint.Y*cosRadians+pivot.Y};

			return rotatedPoint;
		}

	}

}